Skip to content

feat(nextjs): Send the render start of a cached page to the browser - #26397

Merged
s1gr1d merged 3 commits into
developfrom
sig/nextjs-cacheComponents-ticket-20
Nov 16, 2026
Merged

s1gr1d merged 3 commits into
developfrom
sig/nextjs-cacheComponents-ticket-20

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

What

Next.js now writes a sentry-render-start meta tag (whole UNIX seconds) next to sentry-cache-origin. The browser uses it to set page.server_rendering.age on the pageload span, so the UI can show how old the cached HTML was. The browser side is in @sentry/core, so SvelteKit and Nuxt only need to write the tag. They follow in stacked PRs.

Why

The cache_origin link tells you which render produced a cached page, but not how old that page is. That linked span is often not sampled or already gone, so the browser needs the start time itself.

The tag holds the start of the linked render span. Without a recording span, it holds the current time, which is the render start, because Next.js computes the meta tags at the start of prerenderToStream. The attribute comes from getsentry/sentry-conventions#799, which is not merged yet, so the name is a local constant with a TODO.

A Server-Timing header (#26107) does not replace the tag: shared-cacheable responses and Vercel do not send it, and it cannot hold the render time of a cached shell.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 4ae529e (PR test merge using develop at 7f77bb2)

Against: 7f77bb2 (develop) · base run #66275

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.1 kB - -
@sentry/browser - with treeshaking flags 28.3 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.2 kB - -
@sentry/browser (incl. Tracing) 52.28 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.29 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.25 kB - -
@sentry/browser (incl. Tracing, Replay) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.6 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.21 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.6 kB - -
@sentry/browser (incl. Feedback) 47.73 kB - -
@sentry/browser (incl. sendFeedback) 30.69 kB - -
@sentry/browser (incl. FeedbackAsync) 35.69 kB - -
@sentry/browser (incl. Metrics) 31.43 kB - -
@sentry/browser (incl. Logs) 31.71 kB - -
@sentry/browser (incl. Metrics & Logs) 32.37 kB - -
@sentry/react 32.11 kB - -
@sentry/react (incl. Tracing) 54.95 kB - -
@sentry/vue 38.3 kB - -
@sentry/vue (incl. Tracing) 55.24 kB - -
@sentry/svelte 30.12 kB - -
@sentry/remix (Remix 3 client bundle) 58.06 kB - -
CDN Bundle 31.87 kB - -
CDN Bundle (incl. Tracing) 52.7 kB - -
CDN Bundle (incl. Logs, Metrics) 34.67 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.26 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.7 kB - -
CDN Bundle (incl. Tracing, Replay) 90.72 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.09 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.69 kB - -
CDN Bundle - uncompressed 92.98 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.45 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.33 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.08 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.44 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.61 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.02 kB - -
@sentry/nextjs (client) 58.57 kB +0.22% +123 B 🔺
@sentry/sveltekit (client) 53.57 kB +0.17% +90 B 🔺
@sentry/core/server 44.76 kB +0.08% +33 B 🔺
@sentry/core/browser 14.4 kB +0.7% +100 B 🔺
@sentry/node 151.32 kB -0.01% -4 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.3 kB - -
@sentry/node - without tracing 88.56 kB -0.01% -5 B 🔽
@sentry/node - without channel injection 140.26 kB -0.01% -5 B 🔽
@sentry/aws-serverless 98.93 kB -0.01% -7 B 🔽
@sentry/cloudflare (withSentry) - minified 205.88 kB - -
@sentry/cloudflare (withSentry) 477.87 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 231.24 kB +0.09% +188 B 🔺

View base workflow run

A pageload of a cached page links to the render that produced the HTML, but
the age of that HTML is unknown. Next.js now writes a `sentry-render-start`
meta tag next to `sentry-cache-origin`, in whole UNIX seconds. The browser
sets `page.server_rendering.age` on the pageload span.

The tag holds the start of the linked render span. Without a recording span it
holds the current time, because Next.js computes the meta tags at the start of
the prerender.
@s1gr1d
s1gr1d force-pushed the sig/nextjs-cacheComponents-ticket-20 branch from 312694e to c5429d5 Compare November 16, 2026 10:46
@s1gr1d s1gr1d changed the title feat(core): Send the render start of a cached page to the browser feat(nextjs): Send the render start of a cached page to the browser Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 5 not successful, 58 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Failing after 5m Details
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
❌ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Failing after 3m Details
❌ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Failing after 3m Details
❌ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Failing after 5m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (deno) Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (cloudflare) Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 59s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details

@s1gr1d
s1gr1d added this pull request to stack #26401 November 16, 2026 10:59
@s1gr1d

s1gr1d commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c5429d5. Configure here.

@s1gr1d
s1gr1d marked this pull request as ready for review November 16, 2026 12:28
@s1gr1d
s1gr1d requested review from a team and JPeer264 November 16, 2026 12:28
@s1gr1d s1gr1d self-assigned this Nov 16, 2026
@s1gr1d
s1gr1d enabled stacked auto-merge (squash) November 16, 2026 13:05
stacked auto-merge was automatically disabled November 16, 2026 13:06

Auto-merge was disabled for another pull request in the stack


// A pageload starts at the time origin. The server and the browser clocks differ, so a render shortly before the
// pageload can seem to start after it.
function getRenderAge(renderStart: string | null | undefined): number | undefined {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only clamps the lower bound, a sentry-render-start of 0 gives page.server_rendering.age: 1794834076. Should we generally drop attributes that seem implausible? Maybe cap it at a year or whatever?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very unlikely that this happens (I hope the server clocks are quite correct :D). But it's fair to cap it. 1 year seems fine.

A `sentry-render-start` of 0 gave an age of about 57 years. The SDK writes
the value from the server clock, so only a clock that jumped back, for example
to 1970, gives such an age. Sites deploy again within a year, so the browser
sets no `page.server_rendering.age` above one year.
@s1gr1d
s1gr1d enabled stacked auto-merge (squash) November 16, 2026 14:37
stacked auto-merge was automatically disabled November 16, 2026 14:40

Pull Request is not mergeable

…mponents-ticket-20

# Conflicts:
#	dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
#	dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
#	packages/core/src/index.ts
@s1gr1d
s1gr1d merged commit deebe83 into develop Nov 16, 2026
457 of 463 checks passed
@s1gr1d
s1gr1d deleted the sig/nextjs-cacheComponents-ticket-20 branch November 16, 2026 15:06
s1gr1d added a commit that referenced this pull request Nov 16, 2026
#26398)

Stacked on #26397.

## What

SvelteKit now writes the `sentry-render-start` meta tag next to
`sentry-cache-origin` on prerendered and Vercel ISR pages. The browser
sets `page.server_rendering.age` from it, as in #26397.

## Why

The tag holds the start of the linked render span. Without a recording
span (build prerender, unsampled request), it holds the request start
that `sentryHandle` records. The current time would be too late by the
whole render, because Kit calls `transformPageChunk` only after the
render.

`_INTERNAL_getCacheOriginMetaTags` is the new shared writer for both
tags. The old `_INTERNAL_getCacheOriginMetaTag` stays until Nuxt moves
to the new one in the next PR.
s1gr1d added a commit that referenced this pull request Nov 16, 2026
…6399)

Stacked on #26398.

## What

Nuxt now writes the `sentry-render-start` meta tag next to
`sentry-cache-origin` on cached and prerendered pages. The browser sets
`page.server_rendering.age` from it, as in #26397.

## Why

The tag holds the start of the linked render span. Without a recording
span, it holds the request start. Nitro calls `render:html` only after
the whole render, so a Nitro `request` hook records the start on
`event.context`. The hook also fires for prerender requests, and a
background SWR revalidation sees the context of the request that started
it. On Cloudflare, this also gives the right start when the async
context is lost.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants